<template>
  <e-panel v-bind="opts" />
</template>

<script lang="ts" setup>
  import { SysUser } from './model'
  import { usePanel } from '@/components/ext'
  import { FormatFormData } from '@/components/ext/types'

  defineOptions({
    name: 'SysUserList'
  })

  const formatFormData: FormatFormData<SysUser> = async ({ roles, depts, ...formData }) => ({
    ...formData,
    roles: roles?.map(({ id }: any) => id),
    depts: depts?.map(({ id }: any) => id)
  })

  const beforeSubmit: FormatFormData<SysUser> = async ({ roles, depts, ...data }) => ({ roles, depts, user: data })

  const opts = usePanel(SysUser, { formProps: { formatFormData, beforeSubmit } })
</script>

<style scoped></style>
